<include file="Inc/header" />
<div class="margin10px">
	<form name="addpage" method="post" action="<?php echo U('admin/acl/admin_add');?>" onsubmit="return checkF();">
		<table class="mytable">
			<tr>
				<th colspan="2">添加用户</th>
			</tr>
			<tr>
				<td width="100" class="tdf">用户名称：</td>
				<td><input type="text" id="admin_name" name="admin_name" size="40" /><span></span></td>
			</tr>
			<tr>
				<td class="tdf">用户密码：</td>
				<td><input type="password" id="admin_password" name="admin_password" size="40" /><span></span></td>
			</tr>
            <tr>
            	<td class="tdf">所属分组：</td>
                <td>
                    <?php echo $groups;?>
        		</td>
            </tr>
			<tr>
				<td class="tdf" valign="top">用户权限：</td>
				<td>
                	<div class="node_list"></div>
                </td>
			</tr>
			<tr>
				<td class="tdf">&nbsp;</td>
				<td>
                    <input type="checkbox" id="cka" onclick="checkAll(this, 'auth[]')" />全选&nbsp;&nbsp;&nbsp;
                    <input type="submit" value="添加" class="button" />
                </td>
			</tr>
		</table>
	</form>
</div>
<script type="text/javascript">
    $('.cb').live('click', function(){
        var flag = false;
        if($(this).attr('checked')){ flag = true; }
        $(this).parent().find('input[type="checkbox"]').attr('checked', flag);
    });
    //得到分组的权限
	function getGroupAcl(group_id)
    {
		$.ajax({
			url:'<?php echo U('admin/acl/ajax_get_nodes_checkbox');?>',
			data:({'group_id':group_id}),
			dataType:'html',
			success:function(msg){
				if(msg == 'no'){
					$('.node_list').html('');
				}
				$('.node_list').html(msg);
			}
		})
	}
	//检查表单
	function checkF()
    {
		if($.trim($('#admin_name').val())==''){
			$('#admin_name').css('background-color','#ffc');
			$('#admin_name').next('span').html('<font color=red> 用户名不能为空</font>');
			$('#admin_name').focus();
			return false;
		}
		
		if($.trim($('#admin_password').val())==''){
			$('#admin_password').css('background-color','#ffc');
			$('#admin_password').next('span').html('<font color=red> 用户密码不能为空</font>');
			$('#admin_password').focus();
			return false;
		}
		
		if($.trim($('#admin_group_id').val())==''){
			alert('请选择分组');
			return false;
		}
        return true;
	}
</script>
<include file="Inc/footer" />